import { LogicDriver } from "./etc/LogicDriver";
import { updateTween } from "./etc/Tween";
import { GameplayModuleC, GameplayModuleData, GameplayModuleS } from "./module/GameplayModule";
import { GuiModuleC, GuiModuleS } from "./module/GuiModule";
import { ItemModuleC, ItemModuleData, ItemModuleS } from "./module/ItemModule";
import { LotteryModuleC, LotteryModuleS } from "./module/LotteryModule";
import { PetModuleC, PetModuleS } from "./module/PetModule";
import { PickupModuleC, PickupModuleS } from "./module/PickupModule";
import { PlayerModuleC, PlayerModuleData, PlayerModuleS } from "./module/PlayerModule";
import { RankModuleC, RankModuleS } from "./module/RankModule";
import { SoundModuleC, SoundModuleS } from "./module/SoundModule";
import { TerrainModuleC, TerrainModuleS } from "./module/TerrainModule";

@Component
export default class GameLauncher extends mw.Script {
    
    onStart() {
        super.onStart()
        this.onRegisterModule();
        DataStorage.setTemporaryStorage(SystemUtil.isPIE ? true : false);
        this.useUpdate = true
        setInterval(LogicDriver.update, 100)
    }

    protected onUpdate(dt: number): void {
        updateTween()
    }

    protected onRegisterModule(): void {
        ModuleService.registerModule(PlayerModuleS, PlayerModuleC, PlayerModuleData)
        ModuleService.registerModule(ItemModuleS, ItemModuleC, ItemModuleData)
        ModuleService.registerModule(SoundModuleS, SoundModuleC, null)
        ModuleService.registerModule(GuiModuleS, GuiModuleC, null)
        ModuleService.registerModule(TerrainModuleS, TerrainModuleC, null)
        ModuleService.registerModule(GameplayModuleS, GameplayModuleC, GameplayModuleData)
        ModuleService.registerModule(PickupModuleS, PickupModuleC, null)
        ModuleService.registerModule(PetModuleS, PetModuleC, null)
        ModuleService.registerModule(LotteryModuleS, LotteryModuleC, null)
        ModuleService.registerModule(RankModuleS, RankModuleC, null)
    }
}